//
//  SPPetModel.swift
//  SparklingPets
//
//  Created by iOS-Czz on 2023/10/26.
//

import UIKit

class SPPetViewModel{
    var dataSource = [SPPetModel]()
}
extension SPPetViewModel{
    func loadData(_ type:Int, onSuccess: ((_ models: [SPPetModel]) ->Void)?){
        let dataHelper = SPPetModel.getUsingLKDBHelper()
        var sql = "select * from @t"
        if type != 6 {
            sql = "select * from @t where type=\(type)"
        }
        let modelArr = dataHelper.search(withSQL: sql, to: SPPetModel.self) as! [SPPetModel]
        self.dataSource = modelArr
        onSuccess?(self.dataSource)
    }
    
}

@objcMembers
class SPPetModel: STBaseModel,Codable {
    var name = ""
    var type = 0
    var sizeName1 = ""
    var size1 = ""
    var sizeName2 = ""
    var size2 = ""
    var sizeName3 = ""
    var size3 = ""
    var picture = ""
    var isDefault = true
    override class func getTableName() -> String {
        return "SPPetModel"
    }
}
